package com.xiongjie.ClusterCache.listener;

import com.xiongjie.ClusterCache.entity.ClusterCacheEntity;
import org.infinispan.notifications.Listener;
import org.infinispan.notifications.cachelistener.annotation.CacheEntryCreated;
import org.infinispan.notifications.cachelistener.event.CacheEntryCreatedEvent;

@Listener(clustered = true)
public class ClusterCacheListener {

   @CacheEntryCreated
   public void entryCreated(CacheEntryCreatedEvent<String, ClusterCacheEntity> event) {
      if (!event.isOriginLocal()) {
         System.out.printf("-- 实体%s被集群的另一个节点修改\n", event.getKey());
      }else{
         System.out.printf("-- 实体%s被集群的当前节点修改\n", event.getKey());
      }
   }
}
